﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Bitis_KeToanThue_Pro_DungChung.Common;

namespace Bitis_KeToanThue_Pro_DanhMuc.AccessDatabase
{
    public class DanhMucDonVi
    {
        AccessData ac = new AccessData(1);
        public int Xoa(string MaDV)
        {
            SqlParameter[] arrpara = new SqlParameter[1];
            arrpara[0] = new SqlParameter("@MaDV", SqlDbType.Char);
            arrpara[0].Value = MaDV;

            DataTable dt = ac.ftblDocDuLieuSP("sp_dmdv_xoa", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }

        public int Sua(string madv,string tendvmoi)
        {
            SqlParameter[] arrpara = new SqlParameter[2];
            arrpara[0] = new SqlParameter("@MaDV", SqlDbType.Char);
            arrpara[0].Value = madv;

            //arrpara[1] = new SqlParameter("@TenDV", SqlDbType.NVarChar);
            //arrpara[1].Value = tendv;

            arrpara[1] = new SqlParameter("@TenDVNew", SqlDbType.NVarChar);
            arrpara[1].Value = tendvmoi;

            DataTable dt = ac.ftblDocDuLieuSP("sp_dmdv_sua", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int them(string madv,string tendv)
        {
            SqlParameter[] arrpara = new SqlParameter[2];
            arrpara[0] = new SqlParameter("@MaDV", SqlDbType.Char);
            arrpara[0].Value = madv;

            arrpara[1] = new SqlParameter("@TenDV", SqlDbType.NVarChar);
            arrpara[1].Value = tendv;

            DataTable dt = ac.ftblDocDuLieuSP("sp_dmdv_them", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable loadluoi()
        {
            return ac.ftblDocDuLieuSP("sp_dmdv_load", null);
        }
    }
}
